<template>
  <div class="main" style="width: 100%; height: 100%">
    <div class="user-info-box">
      <!-- <img :src="info.head_picture" alt="" class="user-avatar" /> -->
      <img src="https://img0.baidu.com/it/u=3608430476,1945954109&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=494" alt="" class="user-avatar" />
      <div class="user-name">{{ info.nick_name }}</div>
    </div>
    <div class="log-box">
      <div class="title">{{ $t("common.logtitle") }}</div>
      <div class="list">
        <div class="list-item" v-for="(item, index) in list" :key="index">
          <div class="info">
            <!-- <img src="" alt="" class="log-avatar" /> -->
            <div class="log-content">
              {{ $t('common.op.user') }}
              {{ item.username }}(id:{{ item.user_id }}){{ $t('common.op.used') }}{{
                item.request_method
              }}{{ $t('common.op.called') }}{{ item.request_uri }}{{ $t('common.op.method') }}
            </div>
          </div>
          <div class="log-date">{{item.create_time}}</div>
        </div>
      </div>
      <div class="block" style="float: right; margin-top: 20px">
        <!-- <span class="demonstration">显示总数</span> -->
        <el-pagination
          background
          @current-change="fetchData"
          :current-page.sync="page_num"
          :page-size="page_size"
          layout="total, prev, pager, next"
          :total="total"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>
<script>
import userinfo from "@/api/userInfo";
export default {
  data() {
    return {
      list: [],
      info: {
        head_picture: "",
        nick_name: "",
      },
      page_num: 1,
      page_size: 10, //每8个数据一页
      total: 1, //初始化
    };
  },
  created() {
    this.fetchData();
    this.fetchUserInfo();
  },
  methods: {
    fetchData(page = 1) {
      this.page_num = page;
      var vm = this;
      userinfo
        .getSysLoglist(this.page_num, this.page_size)
        //请求成功调用
        .then((resp) => {
          console.log(resp);
          vm.list = resp.data.orderList.list;
          vm.total = resp.data.orderList.total;
        })
        .catch((error) => {});
    },
    fetchUserInfo() {
      var _this = this;
      userinfo
        .getLoginUserInfo()
        //请求成功调用
        .then((resp) => {
          console.log(resp);
          _this.info = resp.data.user;
          console.log(_this.info);
        })
        .catch((error) => {});
    },
  },
};
</script>
<style lang="scss" scoped>
.main {
  background-color: #eaedf1;
  display: block;
  flex: 1;
  flex-basis: auto;
  overflow: auto;
  box-sizing: border-box;
  padding: 20px;
}
.log-box {
  box-sizing: border-box;
  height: calc(100vh - 350px);
  padding: 20px;
  border-radius: 4px;
  background-color: #fff;
  margin-top: 20px;
  .title {
    padding-bottom: 20px;
  }
}
.user-info-box {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 204px;
  color: var(--gray-10);
  background: url("https://p3-armor.byteimg.com/tos-cn-i-49unhts6dw/41c6b125cc2e27021bf7fcc9a9b1897c.svg~tplv-49unhts6dw-image.image")
    no-repeat;
  background-size: cover;
  flex-direction: column;
  border-radius: 4px;
  .user-avatar {
    display: block;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin-bottom: 10px;
    background-color: #c9cdd4;
  }
}
.list {
  height: calc(100% - 90px);
}
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e5e6eb;
  padding-bottom: 12px;
  font-size: 14px;
  padding-top: 12px;
  .info {
    .log-avatar {
      width: 34px;
      height: 34px;
      border-radius: 50%;
      background-color: #c9cdd4;
      margin-right: 10px;
    }
    display: flex;
    align-items: center;
  }
  .log-date {
    color: #666;
    font-size: 14px;
  }
}
</style>